@extends('common.admin_layout')
@section('title','用户管理')
@section('content')
                <div class="app_content_div" id="app_content_div_301Index">
                    <h3>用户管理</h3>
                </div>
                <div>
                    <div style="float:right;">
                        <button type="button" onclick="create()" class="btn btn-primary">新增</button>
                    </div>
                </div>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>id</th>
                        <th>用户名</th>
                        <th>更改密码</th>
                        <th>操作
                        <th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($oUsers as $v)
                    <tr>
                        <th  scope="row">{{$v->id}}</th>
                        <td>{{$v->name}}</td>
                        <td><a style="cursor:pointer;" href="/user/{{$v->id}}/edit">更改密码</a></td>
                        <td>
                            <a href="/user/{{$v->id}}/edit"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a> &nbsp;&nbsp;&nbsp;
                            <a onclick="del({{$v->id}});"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                        </td>
                    </tr>
                    @endforeach
                    </tbody>
                </table>
                {{$oUsers->links('common.admin_page')}}
    <script>
        function  create()
        {
            location.href='/user/create';
        }
        function del(id)
        {
            $.ajax({
                url:'/user/'+id,
                type:'DELETE',
                dataType:'json',
                data:{_token:'{{csrf_token()}}'},
                success:function (data)
                {
                    alert('删除成功');
                    location.href='/user';
                },
                error:function (data)
                {

                }
            });
        }
    </script>


@endsection
